package com.note.chh.notebook.Adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.note.chh.notebook.Model.WeatherModel;
import com.note.chh.notebook.R;
import com.note.chh.notebook.Uitls.WeatherUtils;

/**
 * Created by caihuahui on 2018/3/6.
 */

public class WeatherAdapter extends BaseQuickAdapter<WeatherModel.HeWeather6Bean.DailyForecastBean,BaseViewHolder> {
    public WeatherAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, WeatherModel.HeWeather6Bean.DailyForecastBean item) {
        if (helper.getPosition()==0) {
            helper.setText(R.id.mText_day,"今天");
        } else if (helper.getPosition()==1) {
            helper.setText(R.id.mText_day,"明天");
        } else if (helper.getPosition()==2) {
            helper.setText(R.id.mText_day,"后天");
        }else{
            helper.setText(R.id.mText_day,item.getDate());
        }
        ImageView mImage_weather = helper.getView(R.id.mImage_weather);
        Glide.with(mContext).load(WeatherUtils.getInstance().getUrl(item.getCond_code_d())).into(mImage_weather);
        if (!item.getCond_txt_d().equals(item.getCond_txt_n())) {
            helper.setText(R.id.mText_weather,item.getCond_txt_d()+"转"+item.getCond_txt_n());
        }else{
            helper.setText(R.id.mText_weather,item.getCond_txt_d());
        }
        helper.setText(R.id.mText_weatherWin,item.getWind_dir())
        .setText(R.id.mText_temp,item.getTmp_max()+"/"+item.getTmp_min()+"°C");
    }
}
